home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / Makefile < prev    next >
Makefile  |  1994-08-01  |  16KB  |  502 lines

  1. #
  2. # $Id: Makefile,v 0.91 1994/02/20 00:07:45 zhao Pre-Release $
  3. #
  4. # *. This file is part of BIT shareware package. After the two weeks of 
  5. # *  free evaluation period, you are encouraged (required) to register 
  6. # *  your copy for a small registration fee, which is $35 for personal use
  7. # *  and $50 for commercial, government and institutional use.
  8. # *  
  9. # *  Copyright(c) 1993, 1994 by T.C. Zhao.
  10. # *  All rights reserved.
  11. # *
  12. # *  Permission to use, copy, and distribute this software in its entirety
  13. # *  for non-commercial purposes is hereby granted, provided that the 
  14. # *  above shareware and copyright notices and this permission notice
  15. # *  appear in all copies and their documentation.
  16. # *
  17. # *  This software may be modified for your own use, but modified versions
  18. # *  may not be distributed without prior consent of the author.
  19. # *
  20. # *  This software is provided "as is" without expressed or implied
  21. # *  warranty of any kind.
  22. # *
  23. # *.
  24. #
  25. #  Makefile for BIT
  26. #
  27. #  Usage: make [all] [clean] [veryclean] [install] [man] [sfmt]
  28. #
  29. # all       - the default. generate executables, but do not install them
  30. # install   - all + copy all files to their respective directories
  31. # uninstall - remove installed bit package
  32. # clean     - remove all object files and other stuff from this directory
  33. # veryclean - clean + removing all libraries 
  34. # man       - generate online man page for bit. Resulting file is bit.m.
  35. #             (tbl bit.1 | nroff -man)
  36. # sfmt      - format all routines to a standard style so we can safely
  37. #             apply diffs. The style itself is not important, as 
  38. #             you can format the source whatever way you like when you
  39. #             are editing it. Use GNU indent(1.6 or later) with
  40. #             -fca -nfc1 -cdb -sc -i4 -npcs -ss options
  41. #
  42.  
  43. VERSION=0.91
  44.  
  45. #------------------------------------------------
  46. # where your final executables will go
  47. #------------------------------------------------
  48. BIN = /usr/local/bin
  49.  
  50. #------------------------------------------------
  51. # How to get there from here
  52. #------------------------------------------------
  53. INSTALL = cp
  54.  
  55. #------------------------------------------------
  56. # where to put online helps, and icons, (note no quotes).
  57. # Basically all stuffs that won't change. Enviorment variable
  58. # by the same name overrides this setting
  59. #------------------------------------------------
  60. BITHELP = /usr/local/lib/bit
  61.  
  62. #-------------------------------------------------
  63. # where to find configuration, external filters and other stuff
  64. # modifiable by user.
  65. # Default is ~/.bitrc (expanded at run time)
  66. #
  67. # Enviorment variable by the same name overrides this setting
  68. #-------------------------------------------------
  69. BITDIR = $$HOME/.bitrc
  70.  
  71. #---------------------------------------------------
  72. # Where to put man pages
  73. # To be processed by tbl bit.1 | {nt}roff -man
  74. # PS version of the manual, bit.ps, is in ../docs directory
  75. # and generated by tbl bit.1 | ptroff -t -man
  76. #---------------------------------------------------
  77.  
  78. MANDIR = /usr/local/man/man1
  79.  
  80. #---------------------------------------------------------------
  81. # Where to put temporary files. Default /usr/tmp. 
  82. # The prefered method is to use enviorment variable of the same name
  83. # to override the default
  84. #-----------------------------------------------------------------
  85. #TMPDIR=/usr/tmp
  86.  
  87. #-----------------------------------------------------------------
  88. # CPP defines and their meanings: 
  89. #  Use the default or leave all of them undefined is STRONGLY recommanded.
  90. #
  91. # NO_TIMING    -- Disable showing timing for loading, writing etc, not 
  92. #               terribly  accurate. Mostly for me to timing new algorithms.
  93. # MAIL_AUTHOR  -- Define this flag if you want bit to send me a brief
  94. #                 message when it detects core dumps or other critical errors. 
  95. # F_ID     -- Every routine has its own version number compiled in.
  96. #             main program will always has its id compiled in
  97. # MDEBUG   -- Debug code will be compiled in. (for me only)
  98. # MTRACE   -- Trace code will be compiled in. (don't do this)
  99. # Note that MTRACE includes MDEBUG.
  100. #
  101. # M_DBG    -- Check memeory leaks with a naive method (for me)
  102. # CORE     -- If something is wrong, want to have core
  103. #
  104. # TIGHT_MEM  See following
  105. # MAXMEMK    See following
  106. #
  107. # For various reasons, BIT sometimes keeps two copies of the image in core.
  108. # If memory is tight (say main memory is less than 16 Mbytes or the images 
  109. # in question are large), define TIGHT_MEM and then whenver the memory 
  110. # would've been used by the extra copy is larger than MAXMEMK, the extra 
  111. # copy will not be made. Obviousely, MAXMEMK has meaning only if TIGHT_MEM 
  112. # is defined.  The default value for MAXMEMK is about 3Mbytes.
  113. #
  114. # NOTE: Mixed defines, i.e., some files are compiled with a particular
  115. #       flag defined and others compiled with that flag undefined,
  116. #       can lead to funny things (program does not work, not very funny
  117. #       actuallly). If for whatever reason, a flag is changed, 
  118. #       do a make clean before re-make
  119. #       
  120. # There is a bug in the fontmanager (IRIX4.0.5 only ?) that prevents
  121. # bit from releasing memory used by various fonts, and that could eat
  122. # a lot of memory quickly. If you are not running 4.0.5, you might want
  123. # to define NO_FM_BUG. Also try to view string.ppm and move the windows
  124. # around a few times to see if it core dumps. If it does, you have this
  125. # bug, remove -DNO_FM_BUG and text.o and re-make
  126.  
  127. DEFINES=
  128.  
  129. #--------------------------------------------------------------
  130. # FORMATS
  131. # Define a flag to remove a particular format
  132. # e.g, NO_GIF NO_TIFF etc.
  133. # Note that you can not remove IRIS RGB and scratch files
  134. #
  135. # Currently TIFF is supported thru pnmtotiff/tifftopnm and/or
  136. # fromtiff/totiff, so if you do not have any of these, added
  137. # -DNO_TIFF to the RMFORMAT flag
  138. #
  139. #RMFORMAT=-DNO_TIFF
  140. #
  141.  
  142. #---------------------------------------------------------------
  143. # basic stuff: compiler.
  144. #
  145.  
  146. CC = cc
  147.  
  148. #--------------------------------------------------------------- 
  149. # flags to CC (not counting defines).
  150. #
  151.  
  152. CCFLAGS=-O
  153.  
  154. #CCFLAGS = -ansi -pedantic -Wall -O -Wshadow -Wmissing-prototypes\
  155. # -Wstrict-prototypes -Waggregate-return 
  156. #
  157. #---------------------------------------------------------------
  158. # Loader flags
  159. #
  160.  
  161. LDFLAGS=-O
  162.  
  163. #----------------------------------------------------------------
  164. # System libraries. It is important to use shared library
  165. # as it reduces the final exe file size greatly
  166. #
  167. #  -limage  is for support of IRIS RGB files. On IRIX 3.3, it is
  168. #           in the standard directories. Also, image.h is included
  169. #           in iris.c as <gl/image.h>
  170. #  -lmalloc is allegedly faster. 
  171. #
  172. # If using gcc, need to uncomment the following when linking.
  173. #
  174. #XL=-lX11_s -lXext
  175. #
  176. SYSLIB = -limage -lfm_s -lgl_s $(XL) -lm -lmalloc -lc_s
  177.  
  178. #**********************************************************************
  179. # END OF confiurable flags. Better not to change anything after this
  180. #***********************************************************************
  181.  
  182. HELPMODE = 644
  183. EXEMODE =  711
  184. SHELL = /bin/sh
  185.  
  186. # flags to cc: pure cc flag + cpp flags
  187. CFLAGS=$(DEFINES) $(RMFORMAT) $(CCFLAGS) -Iulib -Iforms/FORMS
  188.  
  189. # define where the FORMS library is
  190. #
  191. # The FORMS library used is based on Version 2.2. Note that this version
  192. # is slightly different from standard Version 2.2 and hence you
  193. # can NOT use the standard version even if you have it. Sorry about
  194. # this. See READ_BIT in forms directory for details
  195. #
  196. GUI_LIB=-Lforms/FORMS -lforms
  197. LGUI=libforms.a
  198.  
  199. # where JPEG libraries. 
  200. #
  201. #  VERSION 4.
  202. #
  203. JPG_LIB=-Ljpeg -ljpeg
  204. LJPG=libjpeg.a
  205.  
  206. #
  207. # MPEG library
  208. #
  209. MPEG_LIB=-Lmpeg -lmpeg
  210. LMPG=libmpeg.a
  211.  
  212. #utilities
  213. UTIL_LIB=-Lulib -lutil
  214. LUTIL=libutil.a
  215.  
  216. USERLIB =$(GUI_LIB) $(JPG_LIB) $(MPEG_LIB) $(UTIL_LIB)
  217. LIBS=$(USERLIB) $(SYSLIB)
  218.  
  219.  
  220. # routines still under testing
  221. TTT= measure.o paint.o browse.o cursors.o  medianf.o #hspec.o
  222.  
  223. # The formats files
  224. FORMATS=iris.o pnm.o jpeg.o gif.o scratch.o ps.o holo.o xbm.o\
  225.         sunrast.o mpeg.o
  226.  
  227. OBJ=$(FORMATS) flist.o  display.o init.o  gl_util.o repaint.o \
  228.      fio.o crop.o  text.o cut.o  quant.o dither.o iutil.o iopen.o\
  229.      gui.o  mdbg.o  getmat.o smooth.o tran2d.o marking.o extbind.o\
  230.      iprocess.o  control.o coledit.o zoom.o pedit.o events.o\
  231.      merge.o $(TTT)
  232.  
  233. OBJS=main.o $(OBJ)
  234.  
  235. CSRC=$(OBJS:.o=.c) clock_mail.c
  236. HDR=bit.h global.h extern.h dmalloc.h utype.h proto.h gluproto.h gui.h\
  237.     uproto.h tsdef.h bm.h curdef.h paint.h
  238.  
  239. # all files that contain copyright notices
  240. CPSRC=$(CSRC) $(HDR) mac.h lookup.h symbol.h Makefile
  241.  
  242. SRC=$(CSRC) $(HDR) mac.h lookup.h symbol.h\
  243.     Makefile copyright 01Readme bit.1 README ChangeLog
  244.  
  245. BIT = bit
  246. CLOCK_MAIL = iclock_mail
  247. MPEG = sgimpeg
  248.  
  249. EXE= $(BIT) $(CLOCK_MAIL)
  250.  
  251. all:  $(EXE) $(MPEG)
  252.  
  253. #**************************************************************
  254. # make install will do the following
  255. #**************************************************************
  256. install: all installexe installhelp installman installmisc
  257.  
  258. installexe: $(EXE) $(MPEG)
  259.     -strip $(EXE) mpeg/$(MPEG)
  260.     -$(INSTALL) $(EXE) mpeg/$(MPEG) $(BIN)
  261.     -@for i in $(EXE) $(MPEG); do chmod $(EXEMODE) $(BIN)/$$i;done
  262.     -@date > $@
  263.  
  264. # all help file, data file, icons
  265. ALLHF=../help/*hlp ../help/*map ../help/*icon ../help/BIT* ../help/*dat\
  266.       ../help/01Readme ../Registration
  267.  
  268. installhelp: $(ALLHF)
  269.     -@if [ ! -d $(BITHELP) ];then mkdir $(BITHELP); fi
  270.     @$(INSTALL) $? $(BITHELP)
  271.     -@chmod $(HELPMODE) $(BITHELP)/*
  272.     -@date > $@
  273.  
  274. # the man page
  275. installman: bit.1 
  276.     -@if [ ! -d $(MANDIR) ];then mkdir $(MANDIR); fi
  277.     -$(INSTALL) $? $(MANDIR)
  278.     -chmod $(HELPMODE) $(MANDIR)/$?
  279.     -@date > $@
  280.  
  281. # other stuff
  282. #../help/*opt
  283. installmisc: ../help/BIT*
  284.     -@if [ ! -d $(BITDIR) ];then mkdir $(BITDIR); fi
  285.     $(INSTALL) $? $(BITDIR)
  286.     -@chmod $(HELPMODE) $(BITDIR)/*
  287.     -@date > $@
  288.  
  289. #*****************************************************************
  290. # make uninstall
  291. #****************************************************************
  292. UNINSTALL= /bin/rm -r 
  293. uninstall: uninstallexe uninstallmisc uninstallman uninstallhelp
  294.  
  295. uninstallexe:;  -(cd $(BIN); $(UNINSTALL) $(EXE) ); /bin/rm -f installexe
  296. uninstallhelp:; -$(UNINSTALL) $(BITHELP); /bin/rm -f installhelp
  297. uninstallmisc:; -$(UNINSTALL) $(BITDIR); /bin/rm -f installmisc
  298. uninstallman:;  -$(UNINSTALL) $(MANDIR)/bit.1; /bin/rm -f installman
  299.  
  300. #***************************************************************
  301. # make clean
  302. #****************************************************************
  303.  
  304. clean:;-/bin/rm -f core a.out installhelp installman installmisc \
  305.            installexe update $(EXE) tags  *.o *.ln *log \
  306.            xx* *~ *.bak *.orig 
  307.  
  308. veryclean: clean
  309.     -/bin/rm -f new
  310.     (cd forms/FORMS; make empty) 
  311.     (cd jpeg; make clean)
  312.     (cd mpeg; make clean)
  313.     (cd ulib; make veryclean)
  314.  
  315.  
  316. $(BIT): $(LJPG) $(LMPG) $(LGUI) $(LUTIL) $(OBJS);
  317.     $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  318.  
  319. $(CLOCK_MAIL):clock_mail.o;  $(CC) $(LDFLAGS) -o $@ clock_mail.o $(LIBS)
  320. $(MPEG):; (cd mpeg; make $@)
  321.  
  322. $(LJPG): ; (cd jpeg; make CC=$(CC) CFLAGS="$(CCFLAGS)" libjpeg.a)
  323. $(LUTIL): ; (cd ulib; make CC=$(CC) CFLAGS="$(CCFLAGS)" )
  324. $(LGUI): ;(cd forms/FORMS; make CC=$(CC) CFLAGS="$(CCFLAGS)" )
  325. $(LMPG): ;(cd mpeg; make CC=$(CC) CFLAGS="$(CCFLAGS)")
  326.  
  327. #
  328. # filter using xstr before built. Slightly smaller executables
  329. # All files will be prepended xx
  330. #
  331. DS=-DBITHELP='"'$(BITHELP)'"' -DCLOCK_MAIL='"'$(CLOCK_MAIL)'"'
  332. xall: xxobj $(CLOCK_MAIL)
  333.     $(CC) -o $(BIT) $(LDFLAGS) xx*.o $(LIBS)
  334.  
  335. xxobj: $(CSRC)
  336.     for i in $?; do $(CC) -E $(CFLAGS) -Ijpeg $(DS) $$i | xstr -c -;\
  337.     mv x.c xx$$i; $(CC) -c $(CFLAGS) $(DS) xx$$i; done;
  338.     xstr; mv xs.c xxs.c
  339.     $(CC) -c $(CFLAGS) -Ijpeg $(DS) xxs.c
  340.     date > $@
  341.  
  342. # Man pages
  343. man:; tbl bit.1 | nroff -man > bit.m
  344.  
  345.  
  346. # general dependencies. stuff depends on bit.h
  347. #
  348.  
  349. CMNH=bit.h utype.h
  350. DIS=-DBITHELP='"'$(BITHELP)'"'
  351.  
  352. jpeg.o    : jpeg.c    $(CMNH) ; $(CC) $(CFLAGS) -Ijpeg -c jpeg.c
  353.  
  354. main.o : main.c $(CMNH) global.h
  355.     @echo const char '*' cmpldate = '"'`date '+%m %e %Y %H'`'";' > date.h
  356.     @cat bitmaps/.note >> date.h
  357.     -$(CC) -c $(CFLAGS) $(DIS) main.c
  358.     @/bin/rm date.h
  359.  
  360. init.o :init.c $(CMNH) extern.h
  361.     $(CC) -c $(CFLAGS) -DCLOCK_MAIL='"'$(CLOCK_MAIL)'"' init.c
  362.  
  363. coledit.o  : coledit.c  $(CMNH)
  364. control.o  : control.c  $(CMNH)
  365. crop.o     : crop.c     $(CMNH)
  366. cut.o      : cut.c      $(CMNH)
  367. display.o  : display.c  $(CMNH)
  368. dither.o   : dither.c   $(CMNH) lookup.h
  369. extbind.o  : extbind.c  $(CMNH)
  370. fio.o      : fio.c      bit.h
  371. flist.o    : flist.c    bit.h
  372. gif.o      : gif.c      $(CMNH)
  373. gl_util.o  : gl_util.c  gluproto.h
  374. cursors.o  : cursors.c  curdef.h
  375. gui.o      : gui.c      gui.h utype.h
  376. holo.o     : holo.c     $(CMNH)
  377. iopen.o    : iopen.c    $(CMNH)
  378. iprocess.o : iprocess.c $(CMNH)
  379. medianf.o  : medianf.c $(CMNH)
  380. iris.o     : iris.c     $(CMNH)
  381. iutil.o    : iutil.c    $(CMNH) lookup.h
  382. marking.o  : marking.c  $(CMNH) bm.h
  383. mdbg.o     : mdbg.c     dmalloc.h 
  384. measure.o  : measure.c  $(CMNH)
  385. paint.o    : paint.c    $(CMNH) paint.h
  386. pedit.o    : pedit.c    $(CMNH)
  387. pnm.o      : pnm.c      $(CMNH)
  388. ps.o       : ps.c       $(CMNH) tsdef.h
  389. quant.o    : quant.c    $(CMNH)
  390. repaint.o  : repaint.c  $(CMNH)
  391. scratch.o  : scratch.c  $(CMNH)
  392. sunrast.o  : sunrast.c  $(CMNH) 
  393. text.o     : text.c     $(CMNH) symbol.h tsdef.h
  394. tran2d.o   : tran2d.c   $(CMNH)
  395. xbm.o      : xbm.c      $(CMNH)
  396. zoom.o     : zoom.c     $(CMNH)
  397.  
  398.  
  399. #**********************************************************
  400. # Tags
  401. #**********************************************************
  402. tags:$(CSRC) ; ctags $(CSRC) *.h
  403.  
  404. #**********************************************************
  405. # LINT
  406. #**********************************************************
  407.  
  408. LSYSLIB=-L/usr/lib -lgl_s -lmalloc -lm -lc_s
  409. LUSERLIB=-L. -lutil -lforms
  410. LINTLIB=$(LUSERLIB) $(LSYSLIB)
  411. #LINTFLAG=$(DEFINES) -Ijpeg -Iulib -Iforms/FORMS -u
  412. LINTFLAG=$(DEFINES) -Ijpeg -Iulib -Iforms/FORMS
  413. LINTFILE=$(OBJS:.o=.ln)
  414.  
  415. # rules 
  416. .SUFFIXES: .ln .c
  417. .c.ln: ; lint -c $(LINTFLAG) $<
  418.  
  419. bitlint:$(LINTFILE); lint $(LINTFLAG) $(LINTFILE) $(LINTLIB)
  420.  
  421. #*******************************************************
  422. #  RCS
  423. #  For uniform verion number, -f may be needed in ci
  424. #*******************************************************
  425. STATE="Pre-Release"
  426. #DATE="1993/10/11"
  427. CIF=-f
  428. update:$(SRC)
  429. #    rcs -i -azhao -U $?
  430.     ci $(CIF) -u$(VERSION) -s$(STATE) -d$(DATE) $?
  431.     (cd ..; ci $(CIF) -u$(VERSION) -s$(STATE) -d$(DATE) Registration)
  432.     @date > update
  433.  
  434. OVERSION=0.91
  435. outdate:
  436.     rcs -o$(OVERSION) $(SRC)
  437.     (cd ..; rcs -o$(OVERSION) Registration)
  438.  
  439. #******************************************************
  440. # Make tar
  441. #******************************************************
  442. FFILES=README FAQ New src help docs Registration
  443. TARFLAG=covdf
  444.  
  445. FTARNAME=bit$(VERSION).tar
  446. ftar: sfmt veryclean
  447.     -mv RCS ..
  448.     -cd ..; tar $(TARFLAG) $(FTARNAME) $(FFILES); mv RCS src
  449. #
  450. # without JPEG
  451. #
  452. JFILES=README FAQ src help docs
  453. JMF=RCS jpeg
  454. JTARNAME=bit$(VERSION)-jpg.tar
  455. jtar: sfmt veryclean
  456.     -mv $(JMF) ..
  457.     -cd ..; tar $(TARFLAG) $(JTARNAME) $(JFILES); mv $(JMF) src
  458.  
  459. # make all tars
  460. alltar: sfmt veryclean
  461.     -mv RCS ..
  462.     -cd ..; tar $(TARFLAG) $(FTARNAME) $(FFILES); mv RCS src
  463.     -mv $(JMF) ..
  464.     -cd ..; tar $(TARFLAG) $(JTARNAME) $(JFILES); mv $(JMF) src
  465. #
  466. # Run bit.1 thru ptroff on NeXt
  467. psman:;    (cd ..;psman)
  468.  
  469. # Tempory store
  470. #
  471. ARCH=../.all.ar
  472. ar:; @ar ruv $(ARCH) $(SRC)
  473. getsrc: ; -@ ar x $(ARCH) $(SRC)
  474. rcp: ; rcp $(ARCH) svec5@menudo:c/sgi
  475.  
  476. PLIB= -Lulib -lutil -Lforms/FORMS -Ljpeg -ljpeg -limage -lforms -lgl -lfm -lm
  477. POBJ=profile.o $(OBJ)
  478. profile: $(POBJ)
  479.     $(CC) -p -o $@ $(POBJ) $(PLIB)
  480.  
  481. profile.o:profile.c
  482.     $(CC) -Iulib -Iforms/FORMS -O -c $?
  483. #
  484. # working format
  485. #
  486. refmt:; (for i in $(CSRC) $(HDR); do refmt $$i $$i; done)
  487. incopyright:; insertcr -v $(CPSRC)
  488. rmcopyright:; insertcr -rv $(CPSRC);
  489. prereg:; /bin/rm -f main.o init.o gui.o
  490.  
  491. #
  492. # All diffs should be applied after running thru indent
  493. #
  494. # Need flag -nfc1 to make header comments correct. 
  495. # Seems not all versions of indent has it ........
  496. #
  497. T=-Trgba_t -TIPTR -Tci_t -Tpc_t -TCMPTR -Tbw_t
  498. CBF=-fca -nfc1 -cdb -sc -i4 -npcs -ss $(T)
  499. sfmt:; indent $(CBF) $(CSRC) $(HDR)
  500.  
  501.